package edu.pku.sei.modeler.model.notation.shape;

import org.w3c.dom.Element;

import edu.pku.sei.modeler.model.notation.shape.extradata.ExtraData;
import edu.pku.sei.modeler.model.xml.XMLUtility;
import edu.pku.sei.modeler.model.notation.core.NotationPackage;


public class Polyline extends Shape {
	static public final int VERTICAL = 0;
	static public final int HORIZONTAL = 1;
	static public final int DIAGONAL = 2;
	static public final int POLYLINE = 3;
	
	
	private int type;
	private ExtraData extraData;
	
	/**
	 * @deprecated
	 */
	public Polyline(){
		super();
		setType(Polyline.HORIZONTAL);
		extraData = null;
	}

	public void setType(int type) {
		this.type = type;
	}

	public int getType() {
		return type;
	}

	public ExtraData getExtraData() {
		return extraData;
	}
	
	
	
	static public Polyline createVertialLine(){
		Polyline p = new Polyline();
		p.setType(Polyline.VERTICAL);
		return p;
	}
	static public Polyline createHorizontalLine(){
		Polyline p = new Polyline();
		p.setType(Polyline.HORIZONTAL);
		return p;
	}
	
	//add by fengchao
	public void serialize(Element root) {
		super.serialize(root);
		XMLUtility.xmlInstance.serializeAttribute(root, NotationPackage.POLYLINE_TYPE, type);
		XMLUtility.xmlInstance.serializeNode(root, NotationPackage.POLYLINE_EXTRADATA, extraData);
	}
	public void deSerialize(Element root) {
		super.deSerialize(root);
		this.type = XMLUtility.xmlInstance.deSerializeInt(root, NotationPackage.POLYLINE_TYPE);
		extraData = (ExtraData) XMLUtility.xmlInstance.deSerializeNode(root, NotationPackage.POLYLINE_EXTRADATA, this);
	}
	//end add
}
